package cn.edu.nwsuaf.examcenter.service.serviceImpl;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.ui.ModelMap;

import cn.edu.nwsuaf.examcenter.model.PageModel;
import cn.edu.nwsuaf.examcenter.pojo.ExerciceItem;
import cn.edu.nwsuaf.examcenter.service.ExerciceItemService;

@Service(value="exerciceItemService")
public class ExerciceItemServiceImpl extends BaseServiceImpl<ExerciceItem> implements ExerciceItemService {

	@Override
	public void loadExerciceItem(ModelMap modelMap) {
		// TODO Auto-generated method stub
		PageModel<ExerciceItem> pageModel = new PageModel<>();
		
		List<ExerciceItem> list = super.findAll(ExerciceItem.class);
		
		pageModel.setTotalrows(list.size());
		pageModel.setList(list);
		
		modelMap.addAttribute("pageModel",pageModel);
		
	}

	@Override
	public void deleteExerciceItem(String itemNo) {
		// TODO Auto-generated method stub
		ExerciceItem item = super.getById(ExerciceItem.class, itemNo);
		
		super.deleteData(item);
	}

	@Override
	public void showItemInfo(String itemNo, ModelMap modelMap) {
		// TODO Auto-generated method stub
		modelMap.addAttribute("exerciceItem",super.getById(ExerciceItem.class, itemNo));
	}

}
